// P2P通话仓库
interface p2pCallState {
  callRemoteId: number
  callRemoteNickname: string
  callRemoteAvatar: string
  isCaller: boolean
}

const p2pCallModule = {
  state: (): p2pCallState => ({
    callRemoteId: 0,
    callRemoteNickname: '',
    callRemoteAvatar: '',
    isCaller: false
  }),
  mutations: {
    SET_CALL_REMOTE_ID(state: p2pCallState, remoteId: number) {
      state.callRemoteId = remoteId
    },
    SET_CALL_REMOTE_NICKNAME(state: p2pCallState, nickname: string) {
      state.callRemoteNickname = nickname
    },
    SET_CALL_REMOTE_AVATAR(state: p2pCallState, avatar: string) {
      state.callRemoteAvatar = avatar
    },
    SET_CALL_IS_CALLER(state: p2pCallState, isCaller: boolean) {
      state.isCaller = isCaller
    },
    FLUSH_ALL_P2P_CALL_DATA(state: p2pCallState) {
      state.callRemoteId = 0
      state.callRemoteNickname = ''
      state.callRemoteAvatar = ''
      state.isCaller = false
    }
  },
  getters: {
    getCallRemoteId: (state: p2pCallState) => state.callRemoteId,
    getCallRemoteNickname: (state: p2pCallState) => state.callRemoteNickname,
    getCallRemoteAvatar: (state: p2pCallState) => state.callRemoteAvatar,
    getCallIsCaller: (state: p2pCallState) => state.isCaller
  }
}

export default p2pCallModule
